package com.bit.demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LXW
 * Date: 2021-12-04
 * Time: 14:51
 */
// 动物类
class Animal {
    protected String name;
    protected int age;

    public Animal (String name,int age) {
        this.name = name;
        this.age = age;
    }
    public void eat () {
        System.out.println(name+"正在eat "+"age: "+age);
    }

}
// 用Dog 继承Animal
class Dog extends Animal {
    public Dog (String name,int age){
        super(name,age); // 使用super调用父类的构造方法
    }

}
// 用Bird继承Animal
class Bird extends Animal {
    public Bird (String name, int age) {
        super(name,age);
    }
    public void fly () {
        System.out.println(name+"正在飞");
    }
}
public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog("haha",5);
        dog.eat();
    }
}
